﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CommonLib;
using CommonLib.Audio;
public class TestReousrceLoad : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
		Debug.Log(GameResource.UIResMgr.IsInit);
		Debug.Log(GameResource.AudioResMgr.IsInit);

		//GameResource.UIResMgr.LoadFromResourceSync("UIRoot", onComplete: (o) =>
		//{
		//	StartCoroutine(corLoad(o));
		//	Instantiate<GameObject>(o, transform);
		//}, onFail: null);
		//Instantiate<GameObject>(go, transform);

		GameResourceLoader.Instance.LoadUIResSync<GameObject>("UIRoot",
			onComplete:
			(o) =>
			{
				Instantiate<GameObject>(o, transform);
			},
			onFail: null,
			cache: false);
		GameResourceLoader.Instance.LoadUIResSync<GameObject>("UIRoot",
			onComplete:
			(o) =>
			{
				Instantiate<GameObject>(o, transform);
			},
			onFail: null,
			cache: false);
		AudioManagerBase.Instance.PlaySound("BGM", "bg01", new AudioDataBase(
			clip: GameResourceLoader.Instance.LoadFromResource<AudioClip>("testClip"),
			name: "Test",
			tag: "Test",
			playMode: AudioPlayMode.None,
			loop: false
			));
		AudioManagerBase.Instance.PlaySound("BGM", "bg02", new AudioDataBase(
				clip: GameResourceLoader.Instance.LoadFromResource<AudioClip>("bgm00"),
				name: "Test0",
				tag: "Test",
				playMode: AudioPlayMode.None,
				loop: false
				));
		AudioManagerBase.Instance.PlaySound("BGM", "bg03", new AudioDataBase(
				clip: GameResourceLoader.Instance.LoadFromResource<AudioClip>("bgm01"),
				name: "Test1",
				tag: "Test",
				playMode: AudioPlayMode.None,
				loop: false
				));
		AudioManagerBase.Instance.PlaySound("BGM", null, new AudioDataBase(
				clip: GameResourceLoader.Instance.LoadFromResource<AudioClip>("bgm02"),
				name: "Test2",
				tag: "Test",
				playMode: AudioPlayMode.None,
				loop: true
				));
	}


	// Update is called once per frame
	void Update()
    {
		if (Input.GetKeyDown(KeyCode.A))
		{
			AudioManagerBase.Instance.PlaySound("BGM", null, new AudioDataBase(
				clip: GameResourceLoader.Instance.LoadFromResource<AudioClip>("testClip"),
				name: "ReTest",
				tag: "Test",
				playMode: AudioPlayMode.None,
				loop: true
				));
		}
	}
}
